﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Autofac;
using AutofacContrib.Scriptable;
using System.IO;
using NUnit.Framework;

namespace AutofacContrib.Tests.Scriptable
{
    [TestFixture]
    public class ScriptableModuleFixture
    {
        [Test]
        public void TestModuleEnabled()
        {
            var builder = new ContainerBuilder();
            builder.RegisterModule(new ScriptableModule() { Enabled = true, ScriptPath = "Builder.py" });
            var container = builder.Build();
            var test = container.Resolve<ITest>();
            Assert.AreEqual("PTEST", test.GetMessage());
        }

        [Test]
        public void TestModuleDisabled()
        {
            var builder = new ContainerBuilder();
            builder.Register<ITest>(c => new Test());
            builder.RegisterModule(new ScriptableModule() { Enabled = false, ScriptPath = "Builder.py" });
            var container = builder.Build();
            var test = container.Resolve<ITest>();
            Assert.AreEqual("TEST", test.GetMessage());
        }
    }
}
